package com.林子祺.CAT旅游系统.controller.contentmanagement;

import com.林子祺.CAT旅游系统.dao.deal.Buy;
import com.林子祺.CAT旅游系统.dao.login.RefreshLoginStatus;
import com.林子祺.CAT旅游系统.dao.placemanagement.PlacePull;
import com.林子祺.CAT旅游系统.dao.ticketmanagement.TicketPull;
import com.林子祺.CAT旅游系统.dao.ticketmanagement.TicketPull2;
import com.林子祺.CAT旅游系统.entity.place.CurrentPlaceData;
import com.林子祺.CAT旅游系统.entity.login.LoginStatus;
import com.林子祺.CAT旅游系统.entity.place.PlaceData;
import com.林子祺.CAT旅游系统.entity.ticket.CurrentTicketData;
import com.林子祺.CAT旅游系统.entity.ticket.TicketData;
import com.林子祺.CAT旅游系统.view.tour.buy.BuyComplete;
import com.林子祺.CAT旅游系统.view.tour.buy.BuyError;

public class OrderTicket {

    public static void buyTicket(String account,int ticket){

        if(ConfirmMoney(CurrentPlaceData.price)){
            TicketPull2.pull(ticket);
            TicketData.OutputData(0);
            Buy.buy(account, ticket);
            RefreshLoginStatus.Refresh(LoginStatus.name);
            TicketData.Refresh();
            BuyComplete.comp();
        }
        else
            BuyError.error();
    }

    private static boolean ConfirmMoney(double cost){
        if(cost <= LoginStatus.money)
            return true;
        else
            return false;
    }

}
